<template>
  <div class="Login_container">
    <div class="login_box">
      <!-- 头像区域 -->
      <!-- <div class="avatar_box">
          <img src="../assets/logo.png" alt />
        </div> -->

      <!-- <div class="block">
          <el-slider v-model="value" show-input class="slide_a"></el-slider>
        </div>-->
      <div class="login_title">欢迎注册SPF-Pal平台</div>
      <!-- 登录表单区域  :model 绑定表单数据  :rules 表单验证规则 这个数据在data里拿到-->
      <!--ref= loginFormRef  ref是表单的实例对象 -->
      <el-form
        :model="loginForm"
        :rules="loginFormRules"
        ref="loginFormRef"
        label-width="0px"
        class="login_form"
      >
        <!-- 用户名  prop给定验证规则-->
        <el-form
          :model="addForm"
          :rules="addFormRules"
          ref="addFormRef"
          label-width="70px"
        >
          <el-form-item  prop="mobile" class="mobile_y">
            <el-input v-model="addForm.username" placeholder="请输入手机号"></el-input>
          </el-form-item>
          <el-form-item  prop="password" >
            <el-input v-model="addForm.password" placeholder="请输入右侧验证码"></el-input>
          </el-form-item>
          <el-form-item label="邮箱" prop="email" >
            <el-input v-model="addForm.email" placeholder="请输入短信获取码"></el-input>
          </el-form-item>
          <el-form-item label="手机" prop="mobile">
            <el-input v-model="addForm.mobile"></el-input>
          </el-form-item>
        </el-form>
        <!-- 按钮区域 -->
        <el-form-item class="btns">
          <el-button @click="resetLoginForm111">下一步</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
    import { log } from "util";
    import { async } from "q";
    export default {
      data() {
          var checkEmail = (rule, value, cb) => {
        // 验证邮箱的正则表达式
        const regEmail = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/
        if (regEmail.test(value)) {
          // 合法的邮箱
          return cb()
        }
        cb(new Error('请输入合法的邮箱'))
      }
      // 验证手机号的规则
      var checkMobile = (rule, value, cb) => {
        // 验证手机号的正则表达式
        const regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
        if (regMobile.test(value)) {
          return cb()
        }
        cb(new Error('请输入合法的手机号'))
      }
        return {

          loginForm: {
            username: "admin",
            password: "123456"
          },
          //loginFormRules表单的验证规则对象
          loginFormRules: {
            username: [
              { required: true, message: "请输入手机号", trigger: "blur" },
              { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" }
            ],
            password: [
              { required: true, message: "请输入登录密码", trigger: "blur" },
              { min: 6, max: 15, message: "长度在 3 到 5 个字符", trigger: "blur" }
            ]
          },
           // 添加用户的表单数据
        addForm: {
          username: '',
          password: '',
          email: '',
          mobile: ''
        },

        // 这是个编辑表单的验证规则
        editFormRules: {
          email: [
            { required: true, message: '请输入邮箱', trigger: 'blur' },
            { validator: checkEmail, trigger: 'blur' }
          ],
          mobile: [
            { required: true, message: '请输入手机号', trigger: 'blur' },
            { validator: checkMobile, trigger: 'blur' }
          ]
        },
        addFormRules: {
          // 添加表单的验证规则对象
          username: [
            { required: true, message: '请输入用户名', trigger: 'blur' },
            {
              min: 3,
              max: 10,
              message: '用户名的长度在3~10个字符之间',
              trigger: 'blur'
            }
          ],
          password: [
            { required: true, message: '请输入密码', trigger: 'blur' },
            {
              min: 6,
              max: 15,
              message: '用户名的长度在6~15个字符之间',
              trigger: 'blur'
            }
          ],
          email: [
            { required: true, message: '请输入邮箱', trigger: 'blur' },
            { validator: checkEmail, trigger: 'blur' }
          ],
          mobile: [
            { required: true, message: '请输入手机号', trigger: 'blur' },
            { validator: checkMobile, trigger: 'blur' }
          ]
        }
    }
     
},
methods: {
       resetLoginForm111(){
         // console.log(this);
         this.$refs.loginFormRef.resetFields();
         // console.log(loginFormRef);
       }
   }

}
</script>

// 

<style lang="less" scoped>
  .Login_container {
    /* background-color: #2b4b6b; */
    height: 100%;
    background: url(http://192.168.0.119:8899/images/%E9%A6%96%E9%A1%B5/u2835.png)
      no-repeat;
    background-size: 100%;
  }
  .login_box {
    width: 650px;
    height: 400px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    .avatar_box {
      height: 130px;
      width: 130px;
      border: 1px solid #eee;
      border-radius: 50%;
      padding: 10px;
      box-shadow: 0 0 10px #ddd;
      position: absolute;
      left: 50%;
      transform: translate(-50%, -50%);
      background-color: #fff;
      img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background-color: #eee;
      }
    }
  }
  .login_form {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
  }
  .btns {
    display: flex;
    justify-content: flex-end;
  }
  .slide_a {
    position: relative;
    top: 60px;
  }
  .login_title {
    color: #fff;
    text-align: center;
    margin-top: 50px;
  }
  
  .el-input{
      width: 300px;
  }
</style>
